package com.tender.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useClusterServers()
                .addNodeAddress(
                      "redis://192.168.18.100:6379",
                        "redis://192.168.18.100:6380",
                        "redis://192.168.18.101:6379",
                        "redis://192.168.18.101:6380",
                        "redis://192.168.18.102:6379",
                        "redis://192.168.18.102:6380"
                        )
                .setTimeout(3000)
                .setMasterConnectionPoolSize(64)
                .setSlaveConnectionPoolSize(64);

        return Redisson.create(config);
    }

    @Bean
    public RedissonSpringCacheManager cacheManager(RedissonClient redissonClient) {
        return new RedissonSpringCacheManager(redissonClient);
    }

}
